package com.example.labSystem.mapper;

import com.example.labSystem.entity.Attendance;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.Date;
import java.util.List;

/**
 * <p>
 * 考勤记录表 Mapper 接口
 * </p>
 *
 * @author 10
 * @since 2024-12-12
 */
@Mapper
public interface AttendanceMapper extends BaseMapper<Attendance> {

    /**
     * 根据用户ID获取考勤记录
     */
    @Select("SELECT * FROM attendance WHERE userID = #{userID}")
    List<Attendance> selectByUserID(String userID);


    @Update("UPDATE attendance " +
            "SET checkOutTime = #{checkOutTime}, remarks = #{remarks} " +
            "WHERE attendanceID = #{attendanceID}")
    int updateOut(@Param("checkOutTime") Date checkOutTime,
                  @Param("remarks") String remarks,
                  @Param("attendanceID") String attendanceID);

}
